<template>
	<view class="content with-tabbar">
		<scroll-view v-if="postForm" class=" pb-100 pl-10 pr-10 bg-fff" style="white-space: normal;" scroll-y>
			<div class=" ">
				<div class="head flex-center pb-34 bor-b">

					<image v-if="postForm.headImg" class="headImg img-104" mode="aspectFill"
						:src="postForm.headImg.indexOf('https://') > -1 ? postForm.headImg : baseUrl + postForm.headImg" />
					<image v-else class="headImg img-104" mode="aspectFill"
						src="https://xingangtong.oss-cn-beijing.aliyuncs.com/common/头像更换.png" />
					<div class="ml-28">
						<div class="fontS28 font-500"><span class="fontS40 ">{{ postForm.name }}·</span>{{ postForm.sex
							=== '0' ? '男' :
							'女' }}</div>
						<div class="fontS24 color6 mt-8">{{ postForm.experienceRequireName }} ｜ {{
							postForm.highEducationName }}
							|
							{{ postForm.age }}岁 ｜ {{ postForm.cityName }}
						</div>
					</div>

				</div>
				<div class="pt-34 pb-34 bor-b">
					<div class="font-bold fontS36 color-0d0 mb-14">联系方式</div>
					<div class="flex-center">
						<div>
							<div class="flex-center mt-10 lh-50 fontS28 color-6">
								<div class="iconfont icon-xiaotubiao-01"></div>
								<div class="ml-20">{{ postForm.phone }}</div>
							</div>
							<div class="flex-center mt-10 lh-50 fontS28 color-6" v-if="postForm.wx">
								<div class="iconfont icon-xiaotubiao-02"></div>
								<div class="ml-20">{{ postForm.wx }}</div>
							</div>
							<div class="flex-center mt-10 lh-50 fontS28 color-6" v-if="postForm.email">
								<div class="iconfont icon-xiaotubiao-03"></div>
								<div class="ml-20">{{ postForm.email }}</div>
							</div>
						</div>

					</div>
				</div>
				<div class="pt-34 pb-34 bor-b">
					<div class="font-bold fontS36 color-0d0 mb-14">求职状态</div>
					<div class="fontS28 lh-50">{{ postForm.jobSeekName }}</div>

				</div>
				<div class="pt-34 pb-34 bor-b" @click="toEdit('creat4')">
					<div class="font-bold fontS36 color-0d0 mb-14">个人优势</div>
					<div class="flex-center lh-50 color-0d0 fontS28">
						<div class="">{{ postForm.advantage }}</div>

					</div>
				</div>
				<div class="pt-34 pb-14 bor-b">
					<div class="flex-center" @click="toEdit('creat5')">
						<div class="font-bold fontS36 color-0d0 mb-14">求职期望</div>

					</div>
					<div v-for="(item, index) in postForm.resumeExpectList" :key="index"
						class="flex-center mb-20 bg-f7 p-20" @click="toEdit('expect', item.id)">
						<div>
							<div class="fontS32 font-500 color-0d0 lh-52">{{ item.expectTypeName || '' }}</div>
							<div class="flex-center fontS28 mt-2 lh-52">
								<div>{{ item.professionName || '' }}</div>
								<div class="ml-36">{{ item.minSalary }}K-{{ item.maxSalary }}K</div>

							</div>
							<div class="color-6 fontS24 lh-44 mt-2">{{ item.cityName || '' }}·{{ item.industryNames ||
								''
							}}
							</div>
						</div>
					</div>
				</div>
				<div class="pt-34 pb-14 bor-b">
					<div class="flex-center">
						<div class="font-bold fontS36 color-0d0 mb-14">工作经历</div>

					</div>
					<div v-for="(item, index) in postForm.resumeWorkList" :key="index"
						class="flex-center mb-20 bg-f7 p-20">
						<div style="width: 100%;">
							<div class=" color-0d0 lh-52 flex-center">
								<div class="fontS32 font-500" style="max-width:300upx;">{{ item.companyName || ''
								}}
								</div>
								<div v-if="item.isInternship" class="isInternship ml-10">实习</div>
								<div class="ml-auto fontS24 color-6">{{ item.startWorkDate }} - {{ item.endWorkDate }}
								</div>
							</div>
							<div>{{ item.professionName || '' }}</div>


							<div class="color-6 fontS24 lh-44 mt-2">工作内容：{{ item.workContent || '' }}</div>
							<!-- 职业优势 -->
							<div></div>
						</div>


					</div>
				</div>
				<div class="pt-34 pb-14 bor-b">
					<div class="flex-center">
						<div class="font-bold fontS36 color-0d0 mb-14">教育经历</div>

					</div>
					<div v-for="(item, index) in postForm.resumeEducationList" :key="index"
						class="flex-center mb-20 bg-f7 p-20">
						<div style="width: calc(100% - 40upx);">
							<div class="color-0d0 lh-52 flex">
								<div class="fontS32 font-500">{{ item.schoolName || '' }}</div>
								<div class="ml-auto fontS24 color-6">{{ item.minStudyDate || "" }} - {{
									item.maxStudyDate || "" }}
								</div>
							</div>
							<div>{{ item.educationName || "" }} · {{ item.majorName || "" }} · {{ item.customMajorName
								|| "" }}</div>
							<div class="color-6 fontS24 lh-44 mt-2 ">在校经历：{{ item.schoolExperience || '' }}</div>
						</div>
					</div>
				</div>
				<div class="pt-34 pb-14">
					<div class="font-bold fontS36 color-0d0 mb-14">资格证书</div>
					<image @click="preView" v-if="postForm.certificate" class="certImg" mode="aspectFill"
						:src="baseUrl + postForm.certificate" />
				</div>



			</div>
		</scroll-view>
		<div class="bottom">
			<div class="submitBtn fontS26" @click="handleToChatRoom">立即沟通</div>

		</div>
		<div v-if="showResume" class="resumeCover" @click="showResume = false"></div>
		<div v-if="showResume" class="resumeBox  pb-20">
			<div class="text-center font-bold bg-fff fontS30 lh-80">选择沟通的岗位</div>
			<scroll-view style="height: calc(70vh - 120upx);" scroll-y>
				<div class="listBox ml-20 mr-20">
					<div v-for="(item, index) in list" :key="index" class="bg-fff p-24 bor-r16 mt-20"
						@click="talkPage(item)">
						<div class="fontS28 font-bold">{{ item.professionName || "" }}</div>
						<div class="flex-center justify-between fontS24 color-6d mt-20 bor-b pb-20">
							<div>{{ item.experienceRequireName || '' }}</div>
							<div>|</div>
							<div>{{ item.minEducationName || '' }}</div>
							<div>|</div>
							<div>{{ item.salary || '' }}</div>
							<div>|</div>
							<div>{{ item.postTypeName || '' }}</div>
							<div>|</div>
							<div>{{ item.cityName || '' }}</div>
						</div>
						<div class="mt-20 flex justify-between">
							<div class="flex flex-direction align-center justify-center">
								<div class="fontS32 font-500">{{ item.viewCnt }}</div>
								<div class="mt-20">看过我</div>
							</div>
							<div class="flex flex-direction align-center justify-center">
								<div class="fontS32 font-500">{{ item.chatCnt }}</div>
								<div class="mt-20">沟通过</div>
							</div>
							<div class="flex flex-direction align-center justify-center">
								<div class="fontS32 font-500">{{ item.resumeCnt }}</div>
								<div class="mt-20">收到简历</div>
							</div>
						</div>


					</div>
					<without v-if="list.length < 1"></without>
				</div>
			</scroll-view>
		</div>
	</view>
</template>

<script>
import { pcResumeDetail } from '@/api/resume'
import { appCompanyPostList } from '@/api/index'
export default {
	computed: {
		userInfo() {
			return this.$store.getters.userInfo || {};
		},
	},
	data() {
		return {
			showResume: false,
			baseUrl: getApp().globalData.baseUrl,
			postForm: null,
			value: '',
			sexList: getApp().globalData.sexList,
			eduList: getApp().globalData.education,
			experienceList: getApp().globalData.experience,
			jobSeekList: getApp().globalData.jobSeek,
			regionList: [],
			postStatus: false,
			userId: '',
			loading: false,
			list: []
		}
	},
	onLoad(option) {
		this.userId = option.userId
		this.getDetail()

	},

	methods: {
		async getList() {

			const { rows } = await appCompanyPostList({
				pageNum: 1,
				pageSize: 99,
				companyId: this.userInfo.companyId,
			})
			this.list = rows
		},
		async preView() {
			uni.previewImage({
				urls: [this.baseUrl + this.postForm.certificate],

			})
		},
		async getDetail() {
			const {
				data
			} = await pcResumeDetail(this.userId)
			if (data.postDescribe) data.postDescribe = data.postDescribe.replace(/\n/g, '<br/>')
			this.postForm = data
			this.loading = true
		},
		async handleToChatRoom() {

			console.log('toUserId ===>', this.postForm.userId);
			if (this.postForm.userId === this.userInfo.userId) {
				uni.showToast({ title: '此为同一账号，不能发起聊天', icon: 'none' })
				return false;
			}
			await this.getList()
			this.showResume = true
			// if (this.postForm.userId) {
			// 	uni.navigateTo({
			// 		url: `/pages/chatroom/chatroom?toUserId=customer_${this.postForm.userId}&nick=${this.postForm.name}&position=position`
			// 	});
			// }
		},
		talkPage(item) {
			console.log('item ====>', item);
			if (this.postForm.userId) {
				uni.navigateTo({
					url: `/pages/chatroom/chatroom?toUserId=customer_${this.postForm.userId}&nick=${this.postForm.name}&jobId=${item.id}&position=position`
				});
			}
		}
	}
}
</script>

<style lang="less" scoped>
.content {
	display: flex;
	flex-direction: column;
	background: #fff;
	padding: 20upx;

}

.resume-box {}

.bottom {
	padding-bottom: calc(constant(safe-area-inset-bottom) + 22upx);
	/*兼容 IOS<11.2*/
	padding-bottom: calc(env(safe-area-inset-bottom) + 22upx);
	/*兼容 IOS>11.2*/
}

.headImg {
	min-width: 110upx;
	min-height: 110upx;
}

.color-0d0 {
	color: #0D0D12;
}

.isInternship {
	height: 32upx;
	line-height: 28upx;
	border-radius: 8upx;
	border: 1px solid #FF6601;
	color: #FF6601;
	font-size: 22upx;
	padding: 0 10upx;

}

.certImg {
	width: 100%;
	height: 300upx;
	padding: 20upx;
	border-radius: 8upx;
	border: 1px dashed #34A76C;
}

.bg-f7 {
	background: #f7f8f7;
}

.resumeCover {
	background: rgba(0, 0, 0, .5);
	position: fixed;
	left: 0;
	top: 0;
	width: 100%;
	height: 100vh;

}

.resumeBox {
	background: #f7f7f7;
	position: fixed;
	left: 0;
	bottom: 0;
	width: 100%;
	height: 70vh;
	border-radius: 16upx 16upx 0 0;
	z-index: 999;
}
</style>
